<template>
  <div>
    <el-dialog
      :title="click_title"
      :append-to-body="true"
      @close="closeDio"
      :visible="dialogTableVisible"
      width="1000px"
      style="padding:20px"
    >
      <div>
        <div v-for="(item,index) in shopsList" :key="index" class="box-menu">
          <p style=" margin-bottom: 24px;" @click="addShops(item)">{{item.title}}(一级)</p>
          <div v-if="item.z && isShopCate" class="box-menu-1">
            <div v-for="(it,i) in item.z" :key="i" class="sa">
              <p @click="addShops(it)">{{it.title}} (二级)</p>
              <span
                v-if="it.z"
                @click="showActive(it.id)"
                :style="{color:(active==it.id?'red':'#ddd')}"
              >[{{active==it.id?'-':'+'}}]</span>
              <!-- {{i%1}}{{i%2}}{{i%3}}{{i%4}} -->
              <div
                v-if="it.z"
                class="box-menu-1"
                style="width: 980px;background: #f9f9f9margin-left: -20px;padding: 0 20px;"
                :style="{left:(toZhuanhuan(i)),marginTop:(active==it.id?'14px':'0')}"
              >
                <div
                  v-for="(its,is) in it.z"
                  class="box-menu-2"
                  :key="is"
                  :class="{activeMenu:active==its.parent_id}"
                >
                  <p style=" margin: 12px 0 12px;" @click="addShops(its)">{{its.title}} (三级)</p>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </el-dialog>
  </div>
</template>
<script>
export default {
  name: "xzShopCate",
  props: {
    show: {
      type: Boolean,
      default: true
    },
    showType: {
      type: String,
      default: "table"
    },
    click_title: {
      type: String,
      default: ""
    }
  },
  data() {
    return {
      shopsList: this.$store.state.tourCateList,
      dialogTableVisible: this.show,
      loading: false,
       active: -1
    };
  },
  methods: {
    toZhuanhuan(i) {
      if (i % 4) {
        return -((i % 4) * 235) + "px";
      }
    },
    showActive(id) {
      if (this.active == id) {
        this.active = -1;
      } else {
        this.active = id;
      }
    },
    addShops(row) {
      row.url_title = "旅游产品分类";
      this.$emit("sendShop", row);
      this.closeDio();
    },

    closeDio() {
      this.$emit("isshow", false);
      this.dialogTableVisible = false;
    }
  },
  watch: {
    show(val1, val2) {
      if (val1 == val2) {
        return;
      }
      this.dialogTableVisible = val1;
      this.currentPage1 = 1;
    },
    dialogTableVisible(val1, val2) {
      if (val1 == val2) {
        return;
      }
      this.$emit("isshow", val1);
    },
    getMaterial(val) {
      this.shopsList = val;
      this.loading = false;
    }
  },
  computed: {
    getMaterial() {
      return this.$store.state.tourCateList;
    }
  },
  create() {
    this.loading = true;
  }
};
</script>
<style lang="less" scoped>
.cate_product {
  display: flex;
  flex-wrap: wrap;
  > li {
    width: 25%;
    // height: 30px;
    line-height: 30px;
    cursor: pointer;
  }
  p:hover {
    color: red;
  }
}
.sa{
  margin-bottom: 24px;
}
.box-menu {
  margin-bottom: 24px;
  p {
    display: inline-block;
    min-width: 168px;
    padding: 0 10px;
    height: 42px;
    line-height: 42px;
    border-radius: 5px;
    background: #f5f5f5;
    text-align: center;
    // margin-bottom: 24px;
    cursor: pointer;
  }
  span {
    color: #a3a3a3;
    margin-left: 12px;
    cursor: pointer;
  }
}
.box-menu-1 {
  display: flex;
  flex-wrap: wrap;
  position: relative;
  transition: all 0.3s linear;
  > div {
    width: 25%;
  }
}
.box-menu-2 {
  width: 940px;
  transition: all 0.3s linear;
  max-height: 0;
  overflow: hidden;
}
.activeMenu {
  max-height: 500px;
}
</style>
